#ifndef     __MOTOR_H__
#define     __MOTOR_H__

#include <ti/devices/msp/msp.h>
#include <ti/driverlib/driverlib.h>
#include <ti/driverlib/m0p/dl_core.h>

typedef struct {
  GPTIMER_Regs *timer_pwm;
  uint32_t channel;
  GPIO_Regs*port1;
  uint32_t pin1;
  GPIO_Regs*port2;
  uint32_t pin2;

  float last_speed;
  float speed;
  float speed_set;
  int direction;
} Motor;

typedef struct{
  GPTIMER_Regs *timer_pwm;
  uint32_t channel;
  int32_t angle_set;
}Servo;


extern Motor motor[2];
extern Servo turnover;

void Motor_Init(Motor *motor, GPTIMER_Regs *timer_pwm, uint32_t channel,
                GPIO_Regs*port1, uint32_t pin1, GPIO_Regs*port2, uint32_t pin2);

void Servo_Init(Servo* steer,GPTIMER_Regs *timer_pwm,uint32_t channel);

void Motor_Driver(Motor *motor, int32_t speed_set, int if_front);

void Servo_Driver(Servo*steer, int32_t angle_set);

#endif